﻿<navigation:Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:DataControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:DataSource="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:KharaPos.Web.Services" xmlns:KharaPos_ViewModels="clr-namespace:KharaPos.ViewModels" 
    x:Class="KharaPos.Views.Catalog.CatalogManagement"
    mc:Ignorable="d"
    d:DesignWidth="640" d:DesignHeight="480"
           Title="CatalogManagement Page">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.079*"/>
            <RowDefinition Height="0.921*"/>
        </Grid.RowDefinitions>
        <TextBlock Grid.RowSpan="2" HorizontalAlignment="Center" FontSize="26.667"><Run Text="Catalog Management"/></TextBlock>
        <Controls:TabControl x:Name="tabControl1" Grid.Row="1">
            <Controls:TabItem Header="Categories">
                <Controls:TabItem.Resources>
                    <DataSource:DomainDataSource
                        x:Key="LookupSource"
                        AutoLoad="True"
                        Height="0"
                        LoadedData="DomainDataSourceLoaded"
                        QueryName="GetCategoriesQuery"
                        Width="0">
                        <DataSource:DomainDataSource.DomainContext>
                            <my:CatalogContext />
                        </DataSource:DomainDataSource.DomainContext>
                    </DataSource:DomainDataSource>
                    <DataSource:DomainDataSource
                        x:Name="CategoryDomainDataSource"
                        AutoLoad="True"
                        Height="0"
                        LoadedData="DomainDataSourceLoaded"
                        QueryName="GetCategoriesQuery"
                        Width="0">
                        <DataSource:DomainDataSource.DomainContext>
                            <my:CatalogContext />
                        </DataSource:DomainDataSource.DomainContext>
                        <DataSource:DomainDataSource.FilterDescriptors>
                            <DataSource:FilterDescriptor 
                                   PropertyPath="Id" 
                                   Operator="IsNotEqualTo" Value="3"/>
                        </DataSource:DomainDataSource.FilterDescriptors>

                    </DataSource:DomainDataSource>
                </Controls:TabItem.Resources>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="10"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>


                    <DataControls:DataGrid
                        AutoGenerateColumns="False" 
                        ItemsSource="{Binding Data, Source={StaticResource CategoryDomainDataSource}}" 
                        x:Name="CategoryDataGrid">
                        <DataControls:DataGrid.Columns>
                            <DataControls:DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100" />
                            <DataControls:DataGridTemplateColumn Header="Parent Category" Width="125">
                                <DataControls:DataGridTemplateColumn.CellEditingTemplate>
                                    <DataTemplate>
                                        <ComboBox 
                                            IsSynchronizedWithCurrentItem="False" 
                                            ItemsSource="{Binding Data, Source={StaticResource LookupSource}}"  
                                            SelectedValue="{Binding ParentId}" 
                                            SelectedValuePath="Id" 
                                            DisplayMemberPath="Name"/>
                                    </DataTemplate>
                                </DataControls:DataGridTemplateColumn.CellEditingTemplate>
                                <DataControls:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Parent.Name}"/>
                                    </DataTemplate>
                                </DataControls:DataGridTemplateColumn.CellTemplate>
                            </DataControls:DataGridTemplateColumn>
                            <DataControls:DataGridTextColumn Binding="{Binding ShortDescription}" Header="Short Description" Width="150" />
                            <DataControls:DataGridTextColumn Binding="{Binding LongDescription}" Header="Long Description" Width="*" />
                        </DataControls:DataGrid.Columns>
                    </DataControls:DataGrid>
                    <StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
                        <Button Content="Save Changes" Click="SaveButtonClick" Margin="5"/>
                        <Button Content="Cancel Changes" Click="CancelButtonClick" Margin="5"/>
                    </StackPanel>
                    <Button Grid.Row="2" HorizontalAlignment="Left" Margin="5" Content="New Category" Click="NewButtonClick"/>
                </Grid>
            </Controls:TabItem>
        	<Controls:TabItem Header="Catalogs">
        		<Controls:TabItem.DataContext>
        			<KharaPos_ViewModels:CatalogManagementViewModel/>
        		</Controls:TabItem.DataContext>
        		<Grid Background="#FFE5E5E5">
        			<ComboBox HorizontalAlignment="Left" Margin="84,171,0,0" VerticalAlignment="Top" Width="150" ItemsSource="{Binding AvailableBUs}" SelectedItem="{Binding SelectedBu, Mode=TwoWay}" DisplayMemberPath="Name"/>
                    <ListBox HorizontalAlignment="Right" Width="150" ItemsSource="{Binding AvailableProducts}"/>
                    <Button Content="Add Products to Catalog"/>
					
        		</Grid>
        	</Controls:TabItem>
        </Controls:TabControl>
    </Grid>
</navigation:Page>
